<include file="public@header"/>
</head>
<style>
    .form-search label{width:300px;}
    .form-search label.date{width:300px;}
    .form-search input.js-date{width:80px;}
    .form-search select{width:auto !important;}
    .groups{overflow:hidden; width:46%; border-right:1px double #0b7ebf; float:left; margin-bottom:50px; padding:4%;}
    .groups1{overflow:hidden; width:45%; float:left}
    .control-group{/*width:95%; margin:5px 5% 5px 0; overflow:hidden; border-bottom:1px dashed #eee */}
    .control-group1{width:90%; margin:10px 5%; overflow:hidden; border-bottom:1px dashed #eee}
    .control-group label{ width:50%; float:left}
    .control-group1 label{ width:100%; float:left}
    .form-horizontal .control-group1 {
        float: left;
        width: 25%;
        margin-bottom: 20px;
    }
    .form-horizontal .control-label {width:100px;}
    .form-horizontal .controls {margin-left:110px;}
    select{width:auto; min-width:210px;}
</style>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('visua')}">{:lang('可视化墓区')}</a></li>
        <li><a href="{:url('sale')}?order_id={$order_id}">墓位信息</a></li>
        <!--<li><a href="{:url('orders/buyer')}">申请人信息</a></li>-->
        <li><a href="{:url('applyer')}?order_id={$order_id}">购墓人信息</a></li>
        <li class="active"><a href="{:url('user')}?order_id={$order_id}">使用人信息</a></li>
<!--        <li><a href="{:url('chooseGoods')}?order_id={$order_id}">商品选购</a></li>-->
<!--        <li><a href="{:url('signContract')}?order_id={$order_id}">合同签订</a></li>-->
<!--        <li><a href="{:url('orderPay')}?order_id={$order_id}">订单支付</a></li>-->
    </ul>
    <form class="form-horizontal js-ajax-form" action="{:url('user')}" method="post">
        <input type="hidden" name="tomb_id" value="{$tomb_id}">
        <input type="hidden" name="order_id" value="{$order_id}">
        <input type="hidden" name="customer_id" value="{$customer_id}">
        <input type="hidden" value="">
        <fieldset>
                <div class="form-group" style="margin-bottom:0">
                    <label class="control-label">寿穴：</label>
                    <div class="col-lg-2">
                        <div class="radio" id="flag">
                            <label>
                                <input  class="flag" type="radio" name="is_shouxue" value="1" >是
                            </label>
                            <label>
                                <input class="flag" type="radio" name="is_shouxue" value="0"  checked="checked">否
                            </label>
                        </div>
                    </div>
                    <label class="control-label" >
                        <div class="btn btn-primary" id="add_user" data-tomb_regulation="{$tomb_regulation}" data-i="1" >添加使用人</div>
                    </label>
                </div>
                <div class="form-group"  style="border-top:1px dashed grey;border-bottom:1px dashed grey;margin: 0 3px 15px 0 ;padding: 10px 0; ">
                    <label class=" control-label">【{$tomb_type_name}】</label>
                    <div class="col-lg-2">
                        <select class="form-control" name="tomb_regulation" disabled >
                            <option value="1" <if condition="1 eq $tomb_regulation">selected</if>>单穴</option>
                            <option value="2" <if condition="2 eq $tomb_regulation">selected</if>>双穴</option>
                            <option value="3" <if condition="3 eq $tomb_regulation">selected</if>>三穴</option>
                        </select>
                    </div>
                </div>
            <for start="0" end="$tomb_regulation">
                    <div   class="now_user" id="now_user_{$i}" data-i="{$i}" <if condition="0 neq $i"> style=" display: none"</if> >

            <div class="form-group">
                <label class=" control-label">逝者姓名</label>
                <div class="col-lg-2">
                    <input type="text" name="deceased_name[]" class="disabled form-control" value="" required <if condition="0 neq $i"> disabled</if>>
                </div>
                <label class="control-label" style="margin-bottom: 20px;">性别</label>
                <div class="col-lg-2">
                    <select name="gender[]" class=" disabled form-control" <if condition="0 neq $i"> disabled</if>>
                        <option value="1">男</option>
                        <option value="2">女</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">生于</label>
                <div class="col-lg-2" style="">
                    <input type="text" class="disabled form-control js-date" name="date_birth[]" required <if condition="0 neq $i"> disabled</if>>
                </div>
                <label class="control-label">卒于</label>
                <div class="col-lg-2" style="">
                    <input type="text" class=" disabled form-control js-date" name="date_death[]" required <if condition="0 neq $i"> disabled</if>>
                </div>
            </div>

            <div class="control-group1" style="width: 100%">
                <label class="control-label">火化证明</label>
                <div class="controls">
                    <input type="hidden" name="cremation_certificate[]" value="">
                    <img src="" id="thumb{$i}-preview" width="135" style="cursor: hand"/>
                    <a href="javascript:uploadOneImage('图片上传','#thumb{$i}');">
                        <h5 class="btn btn-primary">上传</h5>
                    </a>
                    <span class="form-required">*</span>
                </div>
            </div>
                </div>
            </for>

        </fieldset>
        <div class="form-actions">
            <button type="submit" id="save" class="btn btn-primary js-ajax-submit">保存</button>
            <a href="javascript:;" class="btn btn-primary" id="next">下一步</a>
            <!--<a class="btn btn-default" id="js-dialog-close" href="{:url('Comtomb/chooseGoods')}">下一步</a>-->
        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>

<script type="text/javascript">

        $("#next").click(function () {
            var flag = $('#flag input:radio:checked').val();
            var deceased_name = $('input[name="deceased_name[]"]').val();
            var order_id = $('input[name="order_id"]').val();
            console.log(flag==0)
            console.log(!deceased_name)
            console.log(flag == 0  && !deceased_name )
            if (flag == 0  && !deceased_name ) {
                alert("请填写使用人！")
            }else if(flag == 1) {
                 $(this).prop({href: "{:url('chooseGoods')}?is_shouxue=1&order_id="+order_id});
            }
        });



    // 提交订单
    $("#check-btn").click(function () {
        $.post($("form").attr('action'), $("form").serialize(), function (result) {
            if (result.state == 'success') {
                alert("保存成功！");
                $('#js-dialog-close').click();
            } else {
                alert(result.info);
            }
        }, 'json');
    });
    var num = 2;
    $("select[name='cate']").change(function () {
        var pnum = $("select[name='cate']").val();
        if (pnum == 1) {
            $("#new_user").html('');
        }
        num = pnum;
    })

    $('#add_user').click(function () {
        var i= $(this).attr('data-i');
        console.log(i)
        $(this).attr('data-i',parseInt(i)+1)
        $('#now_user_'+i).css("display","block").find('.disabled').attr('disabled',false)
    })
    // 删除使用人
    $(document).on("click", "[name='del_user']", function () {
        $(this).parents("div[name='now_user']").remove();
    })
</script>

</body>
</html>